using UnityEngine;
using System.Collections;
using System;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Linq;

public class DataReader {
    private XmlDataCollectLevel dataCollection = new XmlDataCollectLevel();
    private string path;
    private static DataReader Ins;
    
   public DataReader(){
        path = Application.dataPath + "/Scripts/Levels";
        ReadDataXml();
        Ins = this;        
    }
	public XmlDataCollectLevel CollectionLevels{get{return dataCollection;}}
    public static DataReader GetIns {
        get { return Ins; }
    }
    public DataXml[] ReadDataXml()
    {

        XmlSerializer xmls = new XmlSerializer(typeof(XmlDataCollectLevel));
        StringReader reader = new StringReader(Resources.Load<TextAsset>("gameData").text);
        dataCollection = xmls.Deserialize(reader) as XmlDataCollectLevel;
        return dataCollection.store_levels;

    }
}
public class DataXml{
    [XmlAttribute("Level")]
    public int Level { get; set; }
    [XmlAttribute("Target")]
    public int Target { get; set; }
    [XmlAttribute("Move")]
    public int Move { get; set; }
    [XmlAttribute("Score")]
    public int Score { get; set; }
    [XmlAttribute("Row")]
    public int Row { get; set; }
    [XmlAttribute("Column")]
    public int Column { get; set; }
    [XmlAttribute("Help")]
    public int Help { get; set; }
}

[XmlRoot("GameLevels")]
public class XmlDataCollectLevel{
    [XmlElement("GameLevel")]
    public DataXml[] store_levels = null;    
}
